﻿package com.atn.edamame.tools 
{
    import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	import mx.core.UIComponent;
	import mx.controls.Label;
	import mx.controls.TextInput;
	import com.atn.edamame.*;

	public class InputRepeat extends EdamameControl
	{
		private var waitIndex:int = 90;
		[Embed(source='../../../../pipe.png')]
		private var EmbedImage:Class;
		private var dlabel:Label;
		private var valueInput:TextInput;
		private function enterFrameHandler(event:Event):void
		{
			waitIndex++;
			if ( waitIndex > 100 && edamameParent.drag == false)
			{
				var o:EdamameString = new EdamameString();
				edamameParent.addEdamameObject(o);
				o.x = this.x;
				o.y = this.y + this.height;
				o.value = valueInput.text;
				o.vy = 2;
				waitIndex = 0;
			}
		}

        public override function init():void {
			dlabel = new Label();
            dlabel.text = "Let's input text here";
			dlabel.width = 150;
			dlabel.height = 20;
            addChild(dlabel);
			
			valueInput = new TextInput();
			valueInput.text = "baseball";
			valueInput.width = 200;
			valueInput.height = 20;
            addChild(valueInput);
			
			var ui:UIComponent = new UIComponent();
			var img:Bitmap = new EmbedImage() as Bitmap;
			ui.width = 100;
			ui.height = 30;
			ui.addChild(img);
			addChild(ui);
			dlabel.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
			ui.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
			this.height = 100;
			this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
		
		public override function destroy():void
		{
			removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
			super.destroy();
		}
	}
	
}